package cn.tedu.net;

import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

public class Client {
    public static void main(String[] args) throws Exception {

        Socket socket = new Socket("176.223.3.196", 10086);
        System.out.println("与服务器连接成功");
        //给服务器发出请求
        OutputStream outputStream = socket.getOutputStream();
        String a = new Scanner(System.in).nextLine();
        outputStream.write(a.getBytes(StandardCharsets.UTF_8));

        outputStream.flush();

        InputStream inputStream = socket.getInputStream();
        for (int i = 0; i < 10; i++) {
            int read = inputStream.read();
            char ch = (char) read;
            System.out.print(ch);
        }
        outputStream.close();
        inputStream.close();
    }
}
